﻿/*********************************************************************************
**                                                                              **
**  Copyright (C) 2024 LiLong                                                   **
**  This file is part of RinexFileReader.                                       **
**                                                                              **
**  RinexFileReader is free software: you can redistribute it and/or modify     **
**  it under the terms of the GNU General Public License as published by        **
**  the Free Software Foundation, either version 3 of the License, or           **
**  (at your option) any later version.                                         **
**                                                                              **
**  RinexFileReader is distributed in the hope that it will be useful,          **
**  but WITHOUT ANY WARRANTY; without even the implied warranty of              **
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               **
**  GNU General Public License for more details.                                **
**                                                                              **
**  You should have received a copy of the GNU General Public License           **
**  along with RinexFileReader. If not, see <https://www.gnu.org/licenses/>.    **
**********************************************************************************/
#include "ObservationDataFile.h"
#include "Private/ObservationData.h"

namespace Rinex
{
struct ObservationDataFile::Impl
{
    std::shared_ptr<ObservationData> data;
};

double ObservationDataFile::version() const { return m_impl->data->version; }

SatelliteSystem ObservationDataFile::satelliteSystem() const { return m_impl->data->system; }

const std::string& ObservationDataFile::program() const { return m_impl->data->program; }

const std::string& ObservationDataFile::agency() const { return m_impl->data->agency; }

const std::string& ObservationDataFile::createDateTime() const { return m_impl->data->createDateTime; }

const std::vector<std::string>& ObservationDataFile::comments() const { return m_impl->data->comments; }

const std::string& ObservationDataFile::markerName() const { return m_impl->data->markerName; }

const std::optional<std::string>& ObservationDataFile::markerNumber() const { return m_impl->data->markerNumber; }

const std::string& ObservationDataFile::markerType() const { return m_impl->data->markerType; }

const std::tuple<std::string, std::string>& ObservationDataFile::observerAgency() const { return m_impl->data->observerAgency; }

const std::string& ObservationDataFile::recNumber() const { return m_impl->data->recNumber; }

const std::string& ObservationDataFile::recType() const { return m_impl->data->recType; }

const std::string& ObservationDataFile::recVersion() const { return m_impl->data->recVersion; }

const std::string& ObservationDataFile::antNumber() const { return m_impl->data->antNumber; }

const std::string& ObservationDataFile::antType() const { return m_impl->data->antType; }

const std::tuple<double, double, double>& ObservationDataFile::approxPositionXYZ() const { return m_impl->data->approxPositionXYZ; }

const std::tuple<double, double, double>& ObservationDataFile::antennaDeltaHEN() const { return m_impl->data->antennaDeltaHEN; }

const std::optional<std::tuple<double, double, double>>& ObservationDataFile::antennaDeltaXYZ() const
{
    return m_impl->data->antennaDeltaXYZ;
}

const std::optional<PhaseCenter>& ObservationDataFile::phaseCenter() const { return m_impl->data->phaseCenter; }

const std::optional<std::tuple<double, double, double>>& ObservationDataFile::antennaBSightXYZ() const
{
    return m_impl->data->antennaBSightXYZ;
}

const std::optional<double>& ObservationDataFile::antennaZerodirAZI() const { return m_impl->data->antennaZerodirAZI; }

const std::optional<std::tuple<double, double, double>>& ObservationDataFile::antennaZerodirXYZ() const
{
    return m_impl->data->antennaZerodirXYZ;
}

const std::optional<std::tuple<double, double, double>>& ObservationDataFile::centerOfMassXYZ() const
{
    return m_impl->data->centerOfMassXYZ;
}

const std::optional<std::string>& ObservationDataFile::doi() const { return m_impl->data->doi; }

const std::optional<std::string>& ObservationDataFile::licenseOfUse() const { return m_impl->data->licenseOfUse; }

const std::optional<std::string>& ObservationDataFile::stationInformation() const { return m_impl->data->stationInformation; }

const std::vector<SysObsTypes>& ObservationDataFile::sysObsTypes() const { return m_impl->data->sysObsTypes; }

const std::optional<std::string>& ObservationDataFile::signalStrengthUnit() const { return m_impl->data->signalStrengthUnit; }

const std::optional<double>& ObservationDataFile::interval() const { return m_impl->data->interval; }

const TimeOfObs& ObservationDataFile::timeOfFirstObs() const { return m_impl->data->timeOfFirstObs; }

const std::optional<TimeOfObs>& ObservationDataFile::timeOfLastObs() const { return m_impl->data->timeOfLastObs; }

const std::vector<GLONASSSlotFreq>& ObservationDataFile::glonassSlotFreq() const { return m_impl->data->glonassSlotFreq; }

const std::optional<LeapSeconds>& ObservationDataFile::leapSeconds() const { return m_impl->data->leapSeconds; }

const std::optional<int>& ObservationDataFile::ofSatellites() const { return m_impl->data->ofSatellites; }

const std::vector<PrnOfObs>& ObservationDataFile::prnOfObs() const { return m_impl->data->prnOfObs; }

const std::vector<ObsData>& ObservationDataFile::datas() const { return m_impl->data->datas; }

ObservationDataFile& ObservationDataFile::operator=(const ObservationDataFile& other)
{
    m_impl->data = other.m_impl->data;
    return *this;
}

ObservationDataFile& ObservationDataFile::operator=(ObservationDataFile&& other) noexcept
{
    m_impl = std::move(other.m_impl);
    return *this;
}

ObservationDataFile::~ObservationDataFile() {}

ObservationDataFile::ObservationDataFile(std::shared_ptr<ObservationData> d) : m_impl(std::make_unique<Impl>(d)) {}

ObservationDataFile::ObservationDataFile(ObservationDataFile&& other) noexcept : m_impl(std::move(other.m_impl)) {}

ObservationDataFile::ObservationDataFile(const ObservationDataFile& other) : m_impl(std::make_unique<Impl>(other.m_impl->data)) {}

} // namespace Rinex
